﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HustQQInterface;
using HustQQClient.MsgDispatcher;

namespace HustQQClient.UI
{
    public partial class Login : Form
    {

        public Login()
        {
            InitializeComponent();
            //InterfaceManager.NetManager.RecieveTextFromSingle += new SingleTextMsg(NetManager_RecieveTextFromSingle);
            //InterfaceManager.NetManager.ConfirmRecieveFile += new FileMsg(NetManager_ConfirmRecieveFile);
            //InterfaceManager.NetManager.ConfirmSendFile += new BooleanMsg(NetManager_ConfirmSendFile);
            //InterfaceManager.NetManager.SendFileOver += new Action(NetManager_SendFileOver);
            //InterfaceManager.NetManager.ReceiveFileOver += new FileMsg(NetManager_ReceiveFileOver);
        }

        private void Login_Load(object sender, EventArgs e)
        {
            comboState.SelectedIndex = 0;
            this.Focus();
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (InterfaceManager.NetManager.Login(textID.Text, textPw.Text))
            {
                //登录成功跳转下个界面
                InfoControl.CurrentUser.qq_ID = textID.Text;
                InfoControl.CurrentUser = InterfaceManager.NetManager.GetMyself(InfoControl.CurrentUser.qq_ID);
                InfoControl.MainForm.Show();
                InfoControl.MainForm.Init();
                InfoControl.LoginForm.Hide();
            }
            else
            {
                MessageBox.Show("用户名或密码错误！");
            }
        }

        private void linkRegister_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Register reg = new Register();
            reg.ShowDialog(this);
            reg.Dispose();
        }


        internal void Clear()
        {
            this.textID.Clear();
            this.textPw.Clear();
        }
    }
}
